
//
//  SHPKeyboardCollectionView.swift
//  weibo
//
//  Created by songhuipan on 16/4/25.
//  Copyright © 2016年 songhuipan. All rights reserved.
//

import UIKit
let keyboardCell:String = "keyboardCell"
class SHPKeyboardCollectionView: UICollectionView {
    
    override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
        super.init(frame: frame, collectionViewLayout: UICollectionViewFlowLayout())
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
extension SHPKeyboardCollectionView{
    func setupUI(){
        dataSource = self
        let layout = collectionViewLayout as! UICollectionViewFlowLayout
        layout.scrollDirection = .Horizontal
        layout.minimumInteritemSpacing = 0
        layout.minimumLineSpacing = 0
        layout.itemSize = CGSizeMake(kScreenWidth, 216-37)
        self.bounces = false
        self.showsHorizontalScrollIndicator = false
        self.pagingEnabled = true
        registerClass(SHPKeyboardCell.self, forCellWithReuseIdentifier: keyboardCell)
        
    }
}
extension SHPKeyboardCollectionView:UICollectionViewDataSource{
    
    func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
        return SHPEmoticonTool.sharedTools.emoticonGroup.count
    }
    func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return SHPEmoticonTool.sharedTools.emoticonGroup[section].count
    }
    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier(keyboardCell, forIndexPath: indexPath) as! SHPKeyboardCell
        
        cell.emoticonModels = SHPEmoticonTool.sharedTools.emoticonGroup[indexPath.section][indexPath.item]
        
        return cell
    }
    
}












